package com.lhq.message.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class RabbitMqController {
    @Autowired
    RabbitTemplate rabbitTemplate;

    @GetMapping("/rabbit/sendMessage")
    public String directSendMsg(String message) {
        //为什么不绑定队列，因为交换机+routingkey 就等于匹配队列
        rabbitTemplate.convertAndSend("myDirectExchange", "myDirectRoutingKey", message);
        return "ok";

    }
}
